package com.minshenglife.zanzan.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.minshenglife.zanzan.dao.AccessTokenAndJsapiTicketDao;
import com.minshenglife.zanzan.entity.AccessTokenAndJsapiTicket;
import com.minshenglife.zanzan.service.AccessTokenAndJsapiTicketService;

/**
 * 用户信息service
 * 
 * @author huodd
 *
 */
@Component
@Transactional
public class AccessTokenAndJsapiTicketServiceImpl implements
		AccessTokenAndJsapiTicketService {

	@Resource
	AccessTokenAndJsapiTicketDao dao;
	
	@Override
	public boolean insertAccessTokenAndJsapiTicket(AccessTokenAndJsapiTicket ticket) {
		// TODO Auto-generated method stub
		System.out.println("*****************************");
		try{
			dao.add(ticket);
		}catch(Exception ex){
			ex.printStackTrace();
			return false;
		}
		return true;
	}

	@Override
	public AccessTokenAndJsapiTicket getAccessTokenAndJsapiTicket(String appid) {
		
		AccessTokenAndJsapiTicket ticket = null;
		try{
			
			ticket = dao.get(appid);
		}catch(Exception ex){
			ex.printStackTrace();
			return null;
		}
		return ticket;
	}

	@Override
	public boolean updateAccessTokenAndJsapiTicket(AccessTokenAndJsapiTicket ticket) {
		try{
			dao.update(ticket);
		}catch(Exception ex){
			ex.printStackTrace();
			return false;
		}
		return true;
		
	}

}
